﻿using Newtonsoft.Json;
using System;
using System.IO;

namespace DalamudManager
{
    public class Setting
    {
        static string AppPath => AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

        readonly static string SettingFile = Path.Combine(AppPath, "config.json");

        /// <summary>
        /// 卫月框架路径
        /// </summary>
        public string DalamudPath { get; set; } = Path.Combine(AppPath, "Dalamud");

        /// <summary>
        /// 自动更新
        /// </summary>
        public bool AutoUpdate { get; set; } = true;

        public static Setting Load()
        {
            if (File.Exists(SettingFile))
                return JsonConvert.DeserializeObject<Setting>(File.ReadAllText(SettingFile));

            return new();
        }

        public void Save() => File.WriteAllText(SettingFile, JsonConvert.SerializeObject(this));
    }
}
